home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Screens / DoubleBuffer.s next >
Encoding:
Text File  |  1997-05-01  |  2.2 KB  |  98 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Double Buffering
  3. ;----------------
  4. ;This just shows how to double buffer the screen.  You can also try out
  5. ;triple buffering just by changing the DBLBUFFER flag to TPLBUFFER in the
  6. ;GameScreen.
  7.  
  8.     INCDIR    "INCLUDES:"
  9.     INCLUDE    "games/games_lib.i"
  10.     INCLUDE    "games/games.i"
  11.  
  12. CALL    MACRO
  13.     jsr    _LVO\1(a6)
  14.     ENDM
  15.  
  16.     SECTION    "DoubleBuffer",CODE
  17.  
  18. ;===========================================================================;
  19. ;                             INITIALISE DEMO
  20. ;===========================================================================;
  21.  
  22.     STARTGMS
  23.  
  24. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  25.     move.l    GMSBase(pc),a6
  26.     lea    ScreenTags(pc),a0    ;Add screen for use.
  27.     CALL    AddScreen
  28.     tst.l    d0
  29.     beq.s    .Error_Screen
  30.  
  31.     move.l    Screen(pc),a0
  32.     lea    PictureTags(pc),a1    ;Load background picture.
  33.     move.l    GS_MemPtr1(a0),PicData
  34.     CALL    LoadPic
  35.     tst.l    d0
  36.     beq.s    .Error_Picture
  37.  
  38.     move.l    Picture(pc),a1
  39.     move.l    PIC_Palette(a1),GS_Palette(a0)
  40.     CALL    UpdatePalette
  41.  
  42.     CALL    ShowScreen
  43.  
  44.     bsr.s    Main
  45.  
  46. .ReturnToDOS
  47.     move.l    GMSBase(pc),a6
  48.     move.l    Picture(pc),a1
  49.     CALL    FreePic
  50. .Error_Picture
  51.     move.l    Screen(pc),a0
  52.     CALL    DeleteScreen    ;Give back screen memory etc.
  53. .Error_Screen
  54.     MOVEM.L    (SP)+,A0-A6/D1-D7
  55.     moveq    #ERR_OK,d0
  56.     rts
  57.  
  58. ;===========================================================================;
  59. ;                                MAIN LOOP
  60. ;===========================================================================;
  61.  
  62. Main:    CALL    WaitVBL    ;Nice VBL wait for multi-tasking.
  63.     CALL    SwapBuffers
  64.     moveq    #JPORT1,d0
  65.     moveq    #JT_ZBXY,d1
  66.     CALL    ReadJoyPort
  67.     btst    #MB_LMB,d0
  68.     beq.s    Main
  69.     rts
  70.  
  71. ;===========================================================================;
  72. ;                                  DATA
  73. ;===========================================================================;
  74.  
  75. ScreenTags:
  76.     dc.l    TAGS_GAMESCREEN
  77. Screen:    dc.l    0
  78.     dc.l    GSA_ScrWidth,320
  79.     dc.l    GSA_ScrHeight,256
  80.     dc.l    GSA_Attrib,DBLBUFFER
  81.     dc.l    GSA_AmtColours,32
  82.     dc.l    TAGEND
  83.  
  84. PictureTags:
  85.     dc.l    TAGS_PICTURE
  86. Picture    dc.l    0
  87.     dc.l    PCA_Data
  88. PicData    dc.l    0
  89.     dc.l    PCA_Width,320
  90.     dc.l    PCA_Height,256
  91.     dc.l    PCA_AmtColours,32
  92.     dc.l    PCA_Options,GETPALETTE
  93.     dc.l    PCA_File,.file
  94.     dc.l    TAGEND
  95.  
  96. .file    dc.b    "GMS:demos/data/PIC.Green",0
  97.     even
  98.